# coding: utf-8
import unittest
import Monitor
import Info
from mock import MagicMock
from test.Helpers import PseudoMachine
from Consts import CONST


class VMMonitoringTests(unittest.TestCase):
    
    def test_should_return_stats_for_VM(self):
        #given
        nemeOrId= "mach1"
        toBeReturned = PseudoMachine("mach1", "12345", 1, 200, 300, 1)
        findMachineMock = MagicMock(return_value=toBeReturned)
        vminfo = Info.VMInfo()
        monitor = Monitor.VMMonitoring()
        vminfo.findMachine = findMachineMock
        expected = {CONST.name :"mach1", CONST.id:"12345", CONST.cpucount:1, CONST.memsize:200, CONST.vramsize:300, CONST.status:"powered off"}
        
        #when
        stats = monitor.gatherVMStats(nemeOrId, vminfo)
        
        #then
        findMachineMock.assert_called_once_with(nemeOrId)
        self.assertEqual(expected, stats)
        
def main():
    unittest.main()

if __name__ == '__main__':
    main()